#!/usr/bin/env python
"""
A filter class  that removes comments from files.\n
author: Skip Montanaro
Code taken from http://bugs.python.org/issue1225769#msg48505. 
"""
import csv
import StringIO

class removecomments:
    def __init__(self, f, commentstring="#"):
        self.f = f
        self.commentstring = commentstring

    def next(self):
        line = self.f.next()
        while line.startswith(self.commentstring):
            line = self.f.next()
        return line

    def __iter__(self):
        return self

